package com.my.cd.memo;

/**
 * 主测试类
 */
public class MainTest {
    public static void main(String[] args) {
        MementoCaretaker caretaker = new MementoCaretaker();
        Originator originator = new Originator();
        Originator2 originator2 = new Originator2();

        System.out.println("*****Originator 1*****");
        originator.testState1();
        caretaker.saveMemento("Originator1", originator.createMemento());
        originator.showState();
        originator.testState2();
        originator.showState();
        originator.restoreMemento(caretaker.retrieveMemento("Originator1"));
        originator.showState();

        System.out.println("*****Originator 2*****");
        originator2.testState1();
        originator2.showState();
        caretaker.saveMemento("Originator2", originator2.createMemento());
        originator2.testState2();
        originator2.showState();
        originator2.restoreMemento(caretaker.retrieveMemento("Originator2"));
        originator2.showState();

        //调错不同环境的备忘录的时候，会报错
        System.out.println("*****Originator&&Originator 2*****");
        originator.restoreMemento(caretaker.retrieveMemento("Originator2"));
        originator.showState();
    }
}
